
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="">

    <title>{$sysPageTitle}</title>

    <link href="__PUBLIC__/images/favicon.ico" rel="shortcut icon" />

    <!-- Bootstrap core CSS -->
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-theme.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/dashboard.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/icheck/all.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/select2/select2.min.css" />
    <link rel="stylesheet" href="__PUBLIC__/css/bootstrap-datetimepicker.css" />
</head>

<body>

<include file="Common/topNav" />

<div class="container-fluid">
    <div class="row">
        <include file="Common/leftMenu" />
        <div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
            <div class="cont-title clearfix">
                <div class="title">提现记录</div>
            </div>
            <include file="transfer_search" />
            <div class="table-responsive">
                <table class="table table-striped table-hover" id="tableData">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>用户</th>
                        <th>提现金额</th>
                        <th>提现状态</th>
                        <th>申请时间</th>
                        <th>处理时间</th>
                        <th>付款单号</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <empty name="listData">
                        <tr>
                            <td colspan="10">没有相关记录</td>
                        </tr>
                    </empty>
                    <foreach name="listData" item="data">
                        <tr>
                            <td>{$key|getLineNum=$nowPage,$pageSize}</td>
                            <td>{$data.user.real_name}</td>
                            <td>{$data.money|number_format=2}</td>
                            <td>
                                <switch name="data.status">
                                    <case value="0"><span class="label label-info">处理中</span></case>
                                    <case value="1"><span class="label label-success">提现成功</span></case>
                                    <case value="2"><span class="label label-danger">提现失败</span></case>
                                    <default /><span class="label label-default">其它</span>
                                </switch>
                            </td>
                            <td>{$data.add_time|date="Y-m-d H:i:s",###}</td>
                            <td><if condition="$data['edit_time']">{$data.edit_time|date="Y-m-d H:i:s",###}<else/>-</if></td>
                            <td>{$data.payment_no|default="-"}</td>
                            <td>
                                <if condition="$data['status'] eq 1">
                                    -
                                <else/>
                                    <a thisId="{$data['id']}" thisUser="{$data.user.real_name}" thisMoney="{$data.money}" class="edit-out" href="javascript:void(0);">确认提现</a>
                                </if>
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
                <div class="page">
                    {$page}
                </div>
            </div>
        </div>
    </div>
</div>


<include file="Common/modalHtmls" />
<script type="text/javascript" src="__PUBLIC__/js/jquery.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/common.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/icheck.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/select2/select2.min.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/select2/i18n/zh-CN.js"></script>
<script type="text/javascript" src="__PUBLIC__/js/bootstrap-datetimepicker.js"></script>
<script type="text/javascript">
    $(function () {
        $("#tableData").on("click",".edit-out",function () {
            var $_this = $(this);
            var id = $_this.attr("thisId");
            var msg = '本次提现用户：'+$_this.attr("thisUser")+'，提现金额：'+$_this.attr("thisMoney")+'，确认付款吗？';
            common.confirm("提示", msg, function () {
                var param = {id: id};
                common.ajax("{:U('Admin/Money/setTransfer')}", param, function (rs) {
                    var span = '';
                    if (rs.status) {
                        span = '<span class="label label-success">提现成功</span>';
                        $_this.parent().siblings("td:eq(3)").html(span);
                        $_this.parent().html("-");
                    } else {
                        span = '<span class="label label-danger">提现失败</span>';
                        $_this.parent().siblings("td:eq(3)").html(span);
                    }
                    common.alert("提示",rs.msg);
                });
            });
        });

        var options = {
            url: "{:U('Admin/User/showUserList')}",
            pageSize: 30,
            value: "id",
            name: "name"
        };
        showUserList(options);
        $("#order_from_date,#order_to_date").datetimepicker({
            format: "yyyy-mm-dd",
            language: "ch",
            pickDate: true,
            pickTime: false,
            autoclose: true,
            minView: 2
        });
    });
    function showUserList(options) {
        var select2Option = {
            language: "zh-CN",
            allowClear: true,
            placeholder: options["placeholder"] || "全部",
            ajax:{
                url: options["url"],
                type: "post",
                dataType: "json",
                delay: 250,
                data: function(params){
                    // 传递到后端的参数
                    return {
                        // 搜索框内输入的内容
                        selectInput: params.term,
                        // 当前页
                        curPage: params.page || 1,
                        // 每页显示多少条记录，默认10条
                        pageSize: options["pageSize"] || 30
                    };
                },
                cache:true,
                processResults: function (res, params) {
                    params.page = params.page || 1;
                    var cbData = [];
                    var data = res.data;
                    var len = data.length;
                    for(var i= 0; i<len; i++){
                        var option = {"id": data[i]["id"], "text": data[i]["real_name"]};
                        cbData.push(option);
                    }
                    return {
                        results: cbData,
                        pagination: {
                            more: params.page < res.total
                        }
                    };
                }
            },
            escapeMarkup: function (markup) {
                // 字符转义处理
                return markup;
            },
            // 最少输入N个字符才开始检索，如果想在点击下拉框时加载数据，请设置为 0
            minimumInputLength: 0
        };
        $("#user_id").select2(select2Option);
        var selectedUserId = "{$user_id}";
        if (selectedUserId) {
            var option = new Option("{$searchUserName}", selectedUserId, true, true);
            $("#user_id").append(option);
        }
    }
</script>
</body>
</html>
